

from selenium import webdriver
import time




driver= ''
def open(browser_name):
    global driver
    if browser_name.lower()=='chrome':
        driver= webdriver.Chrome('D:\\pythonglr\\python\\driver\\chromedriver.exe')
    elif browser_name.lower()=='ie':
        driver= webdriver.Chrome('D:\\pythonglr\\python\\driver\\chromedriver.exe')
    else:
        driver= webdriver.Chrome('D:\\pythonglr\\python\\driver\\chromedriver.exe')
def get(url):
    global driver
    driver.get(url)
def send(element_path,content):
    global driver
    try:
        driver.find_element_by_xpath(element_path).send_keys(content)
    except Exception as e:
        print(e)
def close():
    global driver
    driver.close()
    driver= ''
def click(element_path):
    global driver
    try:
        driver.find_element_by_xpath(element_path).click()
    except Exception as e:
        print(e)
def sleep(seconds):
    sends= int(seconds)
    time.sleep(sends)
def assert_word(key_word):
    global driver
    try:
        assert key_word in driver.page_source
    except Exception as e:
        print(e)
''
open('chrome')
get('https://www.sogou.com')
send('//input[@id="query"]','光荣之路自动化测试')
click('//input[@id="stb"]')
sleep(3)
assert_word('艾瑞克老师')
close()

